﻿using AzukiMap.Map;
using AzukiMap.MapSource;

namespace AzukiMap.Layer
{
    public class GoogleMapLayer : MercatorQuadLayer
    {
        GoogleMapSource _gmSource;

        public GoogleMapLayer(GoogleMapSource mapSource, MapCanvas mapCanvas, string name)
            : base(mapSource, mapCanvas, name)
        {
            _gmSource = mapSource;
        }

        protected override string CreateTileReqString(double tileScale, int tileLeft, int tileTop)
        {
            int level = GetScaleLevel(tileScale);
            int tileX = tileLeft / _gmSource.TileWidth;
            int tileY = tileTop / _gmSource.TileHeight;

            GoogleMapLayerType lType = _gmSource.TileType;
            string version = _gmSource.TileVersions[lType];
            string additions = _gmSource.AdditionalParams[lType];

            return version + "&x=" + tileX.ToString() + "&y=" + tileY.ToString() + "&z=" + level.ToString() + additions; 
        }


    }
}
